package com.example.inprinciple.openClosePrinciple.improve;



public class OpenClosedPrinciple {
    public static void main(String[] args) {
        GraphicEditor graphicEditor = new GraphicEditor();
        graphicEditor.drawShape(new Rectangle());
        graphicEditor.drawShape(new Circle());
        graphicEditor.drawShape(new Triangle());
    }
}

class GraphicEditor{
    public void drawShape(MyShape s){
        s.draw();
    }
}

abstract class MyShape{
    int m_type;
    public abstract void draw();
}

class Rectangle extends MyShape{
    Rectangle(){
        super.m_type=1;
    }
    @Override
    public void draw() {
        System.out.println("矩形");
    }
}
class Circle extends MyShape{
    Circle(){
        super.m_type=2;
    }
    @Override
    public void draw() {
        System.out.println("圆形");
    }
}
class Triangle extends MyShape{
    Triangle(){
        super.m_type=3;
    }
    @Override
    public void draw() {
        System.out.println("三角形");
    }
}